// 判断某个属性是否为必选
export type IsRequired<T, K extends keyof T> =
    {} extends Pick<T, K> ? false : true

// 必选属性键
export type RequiredKeys<T> = {
    [K in keyof T]: IsRequired<T, K> extends true ? K : never
}[keyof T]

// 可选属性键
export type OptionalKeys<T> = {
    [K in keyof T]: IsRequired<T, K> extends true ? never : K
}[keyof T]

// 必选属性对象
export type RequiredProperties<T> = Pick<T, RequiredKeys<T>>

// 可选属性对象
export type OptionalProperties<T> = Pick<T, OptionalKeys<T>>

// 提取对象值的联合类型
export type ValueOf<T> = T extends Record<any, infer V> ? V : never

// 必选属性的值类型联合
export type RequiredValues<T> = RequiredProperties<T> extends Record<any, infer V> ? V : never

// 可选属性的值类型联合  
export type OptionalValues<T> = OptionalProperties<T> extends Record<any, infer V> ? V : never

// 总工具类型
export type TypeUtils<T> = {
    // Keys
    RequiredKeys: RequiredKeys<T>
    OptionalKeys: OptionalKeys<T>

    // Properties
    RequiredProperties: RequiredProperties<T>
    OptionalProperties: OptionalProperties<T>

    // Values
    RequiredValues: RequiredValues<T>
    OptionalValues: OptionalValues<T>
}
